Skip to content

fix(e2e): authenticate before testing sidebar visibility#1236

Merged
xuyushun441-sys merged 2 commits intomainfrom
copilot/fix-e2e-test-errors
Apr 14, 2026
Merged

fix(e2e): authenticate before testing sidebar visibility#1236
xuyushun441-sys merged 2 commits intomainfrom
copilot/fix-e2e-test-errors

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

Sidebar E2E tests fail because MSW mock environment has AuthPlugin registered → discovery returns auth.enabled: trueAuthGuard redirects to /login → no sidebar in DOM.

Changes

  • e2e/helpers/auth.ts — New registerAndLogin(page) helper that signs up a test user via the register form UI and waits for redirect to /home
  • e2e/sidebar-text-visibility.spec.ts — Both tests call registerAndLogin() before asserting sidebar state. Removed the redundant page.goto() after auth (full page reload re-initializes MSW handlers, wiping the in-memory session)
  • CHANGELOG.md — Documented fix
// Before: navigates to / → redirected to /login → no sidebar
await page.goto(`${CONSOLE_BASE}/`);
await expect(sidebar).toBeVisible(); // ❌ element not found

// After: register via UI → already on /home with active session
await registerAndLogin(page);
await expect(sidebar).toBeVisible({ timeout: SIDEBAR_VISIBLE_TIMEOUT }); // ✅

Key subtlety: MSW auth state lives in module-scope variables (currentSession in authHandlers.ts), so any page.goto() that triggers a full reload re-runs startMockServer() and resets session to null.

Copilot AI and others added 2 commits April 14, 2026 09:25
The sidebar-text-visibility E2E tests failed because the MSW mock
environment returns auth.enabled: true, causing AuthGuard to redirect
to the login page where no sidebar exists.

- Add e2e/helpers/auth.ts with registerAndLogin() that signs up a test
  user via the register form UI
- Update sidebar-text-visibility.spec.ts to authenticate first
- Increase sidebar locator timeouts for post-auth rendering
- Update CHANGELOG.md

Agent-Logs-Url: https://github.com/objectstack-ai/objectui/sessions/c7f8c74c-dbbe-431a-b308-c1062554bbcd

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectui-demo Ready Ready Preview, Comment Apr 14, 2026 9:43am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectui Ignored Ignored Apr 14, 2026 9:43am

Request Review

@xuyushun441-sys xuyushun441-sys marked this pull request as ready for review April 14, 2026 09:43
@xuyushun441-sys xuyushun441-sys merged commit 2382b30 into main Apr 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants